﻿@model viBook.Models.RegisterModel
<link href="@Url.Content("~/Content/jquery.realperson.css")" rel="stylesheet" type="text/css"/>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.realperson.js")" type="text/javascript"></script>

<script type="text/javascript">
    $("#create_acc_btn").attr("disabled", "disabled");
    
    $("#user_accepts_email").change(function () {
        if ($("#user_accepts_email").is(":checked")) {
            $("#create_acc_btn").removeAttr("disabled");
        }
        else {
            $("#create_acc_btn").attr("disabled", "disabled");
        }
        
    });
    
    $("#defaultReal").realperson({
        length: 6,
        includeNumbers: true,
        hashName: 'realHash'
    });
    
    $("#UserName").focusout(function () {

        var data = {
            UserName: $.trim($("#UserName").val())
        };
        $.ajax({
            cache: false,
            type: "POST",
            url: '@Url.Action("UserValidation","Account")',
            data: data,
            dataType: "json",
            success: function (data) {
                if (!data.Valid) {
                    $("#user_msg").empty().html("<img src='@Url.Content("~/Content/images/invalid-mark-20.png")'/>" + data.Message);

                };
                if (data.Valid) {
                    $("#user_msg").empty().html("<img src='@Url.Content("~/Content/images/available-mark-20.png")'/>Available");
                };
            }
        });

    });

    $("#Email").focusout(function () {
        var data = {
            Email: $.trim($("#Email").val())
        };
        $.ajax({
            cache: false,
            type: "POST",
            url: '@Url.Action("EmailValidation","Account")',
            data: data,
            dataType: "json",
            success: function (data) {
                if (!data.Valid) {
                    $("#email_msg").empty().html("<img src='@Url.Content("~/Content/images/invalid-mark-20.png")'/>" + data.Message);

                };

                if (data.Valid) {
                    $("#email_msg").empty().html("<img src='@Url.Content("~/Content/images/available-mark-20.png")'/>Available");
                };
            }
        });
    });
    
    function newPopup(url) {
        popupWindow = window.open(url, 'popUpWindow', 'height=700,width=600,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no,status=yes');
    }

</script>
